Skip to content

arm: Allow TLS access with -mslow-flash-data#65

Open
jerome-pouiller wants to merge 1 commit intozephyrproject-rtos:zephyr-gcc-14.3.0from
jerome-pouiller:improve-mslow-data-path
Open

arm: Allow TLS access with -mslow-flash-data#65
jerome-pouiller wants to merge 1 commit intozephyrproject-rtos:zephyr-gcc-14.3.0from
jerome-pouiller:improve-mslow-data-path

Conversation

@jerome-pouiller
Copy link

@jerome-pouiller jerome-pouiller commented Jan 13, 2026

Some chips (such as SiWx917 from Silicon Labs) have slow data bus access. The -mslow-flash-data option generates appropriate code for these chips by disabling literal pools. However, the current
implementation completely prevents TLS (Thread Local Storage) variables from working, since ARM does not provide relocations to encode TLS variables directly into instructions - they require literal pools.

This change relaxes the -mslow-flash-data constraint to allow literal pools specifically for TLS accesses. While this results in slower TLS access (hence a warning is emitted), it is preferable to a hard error that prevents TLS usage entirely.

With -mpure-code, literal pools remain completely disabled and TLS access still results in an error.

Few notes:
I wrote this patch for chips with very slow access to the data. However, I also tested -mslow-flash-data on chips not impacted by the issue and I have also seen 5-10% of performances improvements on these chips. Generalisation of this flag is out of the scope of this PR, but it is worth to be mentioned.

I believe this patch could be accepted by the upstream. I am waiting for comment from Zephyr community before to submit it.

Copy link

@keith-packard keith-packard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems completely reasonable; the -mslow-flash-data documentation says "literal load is minimized for better performance", and as TLS offsets cannot be relocated any other way, then the compiler should continue to use literal loads for them. At least until someone goes through the work of defining TLS relocations within instructions.

Some chips (such as SiWx917 from Silicon Labs) have slow data bus
access. The -mslow-flash-data option generates appropriate code for
these chips by disabling literal pools. However, the current
implementation completely prevents TLS (Thread Local Storage) variables
from working, since ARM does not provide relocations to encode TLS
variables directly into instructions - they require literal pools.

This change relaxes the -mslow-flash-data constraint to allow literal
pools specifically for TLS accesses. While this results in slower TLS
access (hence a warning is emitted), it is preferable to a hard error
that prevents TLS usage entirely.

With -mpure-code, literal pools remain completely disabled and TLS
access still results in an error.

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
@jerome-pouiller jerome-pouiller force-pushed the improve-mslow-data-path branch from a98306e to e354a69 Compare January 29, 2026 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants

Comments